package com.ruoyi.web.controller.example;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;

import com.ruoyi.example.domain.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
@Anonymous
@RestController
@RequestMapping("/bind")
@Api(tags = "参数绑定")
public class BindController<user> {
   @ApiOperation("根据用户名和性别获取用户信息")
   @ApiImplicitParams({
           @ApiImplicitParam(name = "name", value = "用户名称", dataType = "String", dataTypeClass = String.class),
           @ApiImplicitParam(name = "sex", value = "用户性别", required = true,dataType = "String", dataTypeClass = String.class),
   })
    @GetMapping ("/names")
    public String getUsername(@RequestParam(value = "name",required = false) String userName,
                              @RequestParam(value="sex") String sex) {
        return userName + "   "+ sex;
    }
    @ApiOperation( "获取用户id")
    @ApiImplicitParam(name = "id", value = "用户id", dataType = "String", dataTypeClass = String.class,required = true,paramType = "path")
    @GetMapping("/ids/{id}")
    public String getUserId(@PathVariable("id") String userid){
        return userid;
    }
    @ApiOperation("新增用户")
    @ApiImplicitParam(name = "user", value = "用户对象", dataTypeClass = User.class,paramType = "body")
    @PostMapping("/users")
    public AjaxResult insertUser(@RequestBody User user){
        return AjaxResult.success(user);
    }

}
